package xframe.init;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import xframe.common.StartClass;
import xframe.util.db.DBConnector;

public class ADBConnectTest implements StartClass{

    public ADBConnectTest(){}

    public void service(HashMap param){
        System.out.println(" Database Connection ~ " + param.get("ADBConnectTest"));
        Statement stmt = null;
        ResultSet rs = null;
        Connection con = null;
		try {
			con = DBConnector.getConnection();
			
			stmt = con.createStatement();
//	        rs = stmt.executeQuery("SELECT sysdate  aaa from dual");
	        rs = stmt.executeQuery("SELECT now()  aaa");
	        
	        if(rs.next()){
	        	System.out.print("[DB Check / Time] Now :"+rs.getString("aaa"));
	        	System.out.println(".........Connection Ok!");
	        }
	        
	        rs.close();
	        stmt.close();
		} catch (ClassNotFoundException e) {
			System.out.println(".........Connection fail!");
			e.printStackTrace();
		} catch (SQLException e) {
			System.out.println(".........Connection fail!");
			e.printStackTrace();
		}finally{
			try {
				DBConnector.release(con, stmt, rs);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
        
    }
    
    
}
